﻿/*****************************************************************************
	SNEGA STG GAME ENGINE 0.7a
	Copyright (C) 2009, Xiaohan Tian (snega0223)
	
	http://code.google.com/p/sng-actionscript-stg-engine/
	
	This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License(LGPL) as
	published by the Free Software Foundation, either version 3 of the 
	License, or(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.
	
	You should have received a copy of the GNU Lesser General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

package com.sng.stg.game.event 
{
	import com.sng.stg.game.StageViewer;
	import flash.display.Bitmap;
	
	/**
	 * ...
	 * @author snega
	 */
	public class PassingStageToNext extends ContinuousEvent
	{
		protected var _url:String = "";
		protected var _bitmap:Bitmap = null;
		
		public function PassingStageToNext(url:String) 
		{
			this._url = url;
		}
		
		override public function start(stage:StageViewer):void {
			trace("victory in current stage");
			
			this._stage = stage;
			
			this._bitmap = new Bitmap(stage._imageBitmapMap["stage_clear"]);
			
			this._bitmap.alpha = 0;
			
			stage._2dMask.addChild(this._bitmap);
		}
		
		override public function process():void {
			this._stage._frame--;
			
			if (this._bitmap.alpha != 1) {
				this._bitmap.alpha += 0.01;
			}
			else if (this._stage._keyboardStatus[StageViewer.KEY_Z]) {
				this._stage.reload(this._url);
			}
		}
		
	}
	
}